package com.godyao.framework.utils;

/**
 *  1、获取当前线程的ContextClassLoader
 * 	2、获取{@link ClassUtils}类对应的ClassLoader
 * 	3、获取系统ClassLoader（{@link ClassLoader#getSystemClassLoader()}）
 * @author missw
 */
public class ClassUtils {
    public static ClassLoader getDefaultClassLoader() {
        ClassLoader cl;
        cl = Thread.currentThread().getContextClassLoader();
        if (cl == null) {
            cl = ClassUtils.class.getClassLoader();
            if (cl == null) {
                cl = ClassLoader.getSystemClassLoader();
            }
        }
        return cl;
    }

    public static boolean isCglibProxyClass(Class<?> clazz) {
        return (clazz != null && isCglibProxyClassName(clazz.getName()));
    }

    private static boolean isCglibProxyClassName(String className) {
        return (className != null && className.contains("$$"));
    }
}
